package com.tiger.converter;

import java.time.LocalTime;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

import org.apache.commons.lang3.StringUtils;

@Converter
public class LocalTimeConverter implements AttributeConverter<LocalTime, String> {
	@Override
	public String convertToDatabaseColumn(LocalTime entityValue) {
		return entityValue == null ? null : entityValue.toString();
	}
	
	@Override
	public LocalTime convertToEntityAttribute(String databaseValue) {
		return StringUtils.isEmpty(databaseValue) ? null : LocalTime.parse(databaseValue);
	}

}
